#ifndef __REACTOR_THREADPOOL_H__
#define __REACTOR_THREADPOOL_H__

#include "tcp_server.hpp"
#include "pool.hpp"

namespace rocket 
{


class reactor_threadpool
{
public:
    reactor_threadpool(int port,string ip,int pool_capacity=8,int task_list_capacity=20) ;
    ~reactor_threadpool() ;
    void start();
    void stop();
    void set_callback(function<void(shared_ptr<tcp_link>)>callback_new,
            function<void(shared_ptr<tcp_link>)>callback_old,
            function<void(shared_ptr<tcp_link>)>callback_close);
private:
//    void my_task(shared_ptr<tcp_link>link,string data);
    void new_link(shared_ptr<tcp_link>new_one);
    void old_link(shared_ptr<tcp_link>new_one);
    void close_link(shared_ptr<tcp_link>new_one);


private:
    pool _pool;
    tcp_server _server;
    function<void()>_task;
};

}//end of namespace rocket


#endif // __REACTOR_THREADPOOL_H__

